﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HotelProject
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
            
        }

        protected void buttLogin_Click(object sender, EventArgs e)
        {
            try
            {
                MySQLDatabaseConnector database = new MySQLDatabaseConnector();

                // if the user is valid return Homepage

                registeredUser userPulled = database.getUser(userNameTextBox.Text);
                if (userPulled != null && userPulled.userPassword == passwordTextBox.Text)
                {
                    Session["currentUser"] = userPulled;
                    Response.Redirect("~/loginSuccess.aspx");
                }

            }
           
            catch (Exception)
            {
                // do nothing
                invalidLabel.Visible = true;
            }

          
        }
    }
}